import {reqGetSongDeatilData} from '@/api/songdetail'
import {GET_SONG_DEATILDATA} from './mutation-types'

export default {
    namespaced:true,
    state:{
      // 整个歌单详情页的数据
      songDetail:{},
      // 详情页右边喜欢这个歌单的
      songDetailRigth:[],
      // 需要传给歌曲列表的，多少首歌和播放次数
      songListDetail:{},
      
      /* playlist 包含详情头部 playlist{
         subscribers 包含喜欢这个歌单的
         creator 作者相关
         tracks 歌曲列表相关
         } 
         
         */

    },
    actions:{
      // 获取歌单详情
      async getSongDeatilData({commit},id){

        const {playlist} = await reqGetSongDeatilData(id)
        commit("GET_SONG_DEATILDATA",playlist)
      },
    },
    mutations:{
      [GET_SONG_DEATILDATA](state,playlist){
        state.songDetail=playlist
        state.songDetailRigth=playlist.subscribers
        state.songListDetail={
          songNum:playlist.trackCount,
          playCount:playlist.playCount
        }
       
      }
    },
  }